find_best_match_unit Subroutine

public subroutine find_best_match_unit(kohonen_map, current_prototype, ihit, jhit, khit, dist_hit)

Subroutine to calculate the best match unit

Type Bound

self_organizing_map

Arguments

Type IntentOptional Attributes Name
class(self_organizing_map) :: kohonen_map

A self_organizing_map object

type(kohonen_prototype), intent(inout) :: current_prototype

A kohonen_prototype object

integer, intent(out) :: ihit

Integer variables for the coordinates of the BMU

integer, intent(out) :: jhit

Integer variables for the coordinates of the BMU

integer, intent(out) :: khit

Integer variables for the coordinates of the BMU

real(kind=wp), intent(out) :: dist_hit

Real variable with the distance to the BMU


Calls

proc~~find_best_match_unit~~CallsGraph proc~find_best_match_unit self_organizing_map%find_best_match_unit float float proc~find_best_match_unit->float none~distance~8 kohonen_prototype%distance proc~find_best_match_unit->none~distance~8 calculate calculate none~distance~8->calculate none~get_prototype kohonen_prototype%get_prototype none~distance~8->none~get_prototype

Called by

proc~~find_best_match_unit~~CalledByGraph proc~find_best_match_unit self_organizing_map%find_best_match_unit proc~train_som_data self_organizing_map%train_som_data proc~train_som_data->proc~find_best_match_unit proc~external_train_map self_organizing_map%external_train_map proc~external_train_map->proc~train_som_data proc~train_som train_som proc~train_som->proc~train_som_data

Variables

Type Visibility Attributes Name Initial
integer, public :: debug_option
integer, public :: idbg
integer, public :: ix
integer, public :: iy
integer, public :: iz
integer, public :: number_variables
real(kind=wp), public :: dist

Source Code

    subroutine find_best_match_unit(kohonen_map,current_prototype,ihit,jhit,khit,dist_hit)
!========================================================================================
!! Subroutine to calculate the best match unit
        class(self_organizing_map) :: kohonen_map
!! A `self_organizing_map` object
        type(kohonen_prototype),intent(inout) :: current_prototype
!! A `kohonen_prototype` object
        integer,intent(out) :: ihit,jhit,khit
!! Integer variables for the coordinates of the BMU
        real(kind=wp),intent(out) :: dist_hit
!! Real variable with the distance to the BMU
        integer :: debug_option,idbg,ix,iy,iz,number_variables
        real(kind=wp) :: dist
!
        idbg=kohonen_map%parameters%idbg;
        debug_option=kohonen_map%parameters%debug_level;
        number_variables=kohonen_map%parameters%number_variables1*&
                       kohonen_map%parameters%number_variables2
        ihit = 0;
        jhit = 0;
        khit = 0;
        dist_hit = 1.0e7;
        !$OMP parallel do   
        do iz = 1, size(kohonen_map%grid,3)  
            do iy = 1, size(kohonen_map%grid,2)
                do ix = 1,size(kohonen_map%grid,1)
                    dist = 0.0_wp;
                    dist=kohonen_map%grid(ix,iy,iz)%distance(current_prototype,&
                        kohonen_map%distance_function);
                    !write(*,*) 'dist= ',dist
                    if(debug_option > 0) then
                        call kohonen_map%grid(ix,iy,iz)%print(idbg);
                        write(idbg,*) ix,iy,iz,dist;
                    endif
                    dist = dist/float(number_variables);
                    if (dist < dist_hit) then
                        dist_hit = dist;
                        ihit = ix;
                        jhit = iy;
                        khit = iz;
                    endif
                enddo!ix
            enddo!iy
         enddo!iz
         !$OMP end parallel do   
!
!        write(*,*) 'find= ',ihit,jhit,khit,dist_hit
      return
!
    end subroutine find_best_match_unit